/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SLE_DISCOVER_ANNOUNCE_PARCEL_H
#define SLE_DISCOVER_ANNOUNCE_PARCEL_H

#include <cstdint>
#include <memory>
#include "parcel.h"
#include "sle_announce_config.h"
#include "sle_error_code.h"

namespace OHOS {
namespace NearLink {
namespace SleStandard {
class AnnounceParam : public Parcelable {
public:
    AnnounceParam() = default;
    explicit AnnounceParam(const SleAnnounceParam &param);
    ~AnnounceParam() = default;

    bool Marshalling(Parcel &parcel) const override;
    static AnnounceParam *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToSleAnnounceParam(SleAnnounceParam &param) const;
    static SleErrorCode CheckAnnounceParam(const SleAnnounceParam &param);

public:
    uint8_t handle_;
    uint8_t mode_;
    uint8_t role_;
    uint8_t level_;
    uint32_t anneIntervalMin_;
    uint32_t anneIntervalMax_;
    uint8_t anneChannelMap_;
    uint16_t connIntervalMin_;
    uint16_t connIntervalMax_;
    uint16_t connLatency_;
    uint16_t connTimeout_;
};

class AnnounceData : public Parcelable {
public:
    AnnounceData() = default;
    explicit AnnounceData(const SleAnnounceData &data);
    ~AnnounceData() = default;

    bool Marshalling(Parcel &parcel) const override;
    static AnnounceData *Unmarshalling(Parcel &parcel);
    bool ReadFromParcel(Parcel &parcel);

    void ConvertToSleAnnounceData(SleAnnounceData &data) const;
    static SleErrorCode CheckAnnounceData(const SleAnnounceData &data);

public:
    uint16_t length_;
    std::unique_ptr<uint8_t[]> data_;
    uint16_t rspLength_;
    std::unique_ptr<uint8_t[]> rspData_;
};
} // SleStandard
} // NearLink
} // OHOS

#endif // SLE_DISCOVER_ANNOUNCE_PARCEL_H